<html lang="en"><head></head><body><form id="mainForm" method="post" action="http://plnkr.co/edit/?p=preview" target="_self"><input type="hidden" name="files[app/app.component.ts]" value="import { Component } from 'angular2/core';
import { HTTP_PROVIDERS } from 'angular2/http';
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router';
import 'rxjs/Rx'; // load the full rxjs

import { CharacterListComponent } from './characters/character-list.component';
import { CharacterComponent } from './characters/character.component';
import { CharacterService } from './characters/character.service';
import { VehicleListComponent } from './vehicles/vehicle-list.component';
import { VehicleComponent } from './vehicles/vehicle.component';
import { VehicleService } from './vehicles/vehicle.service';
import { CONFIG } from './config';

@Component({
  selector: 'story-app',
  templateUrl: 'app/app.component.html',
  styles: [`
    nav ul {list-style-type: none;}
    nav ul li {padding: 4px;cursor: pointer;display:inline-block}
  `],
  directives: [ROUTER_DIRECTIVES],
  providers: [
    HTTP_PROVIDERS,
    ROUTER_PROVIDERS,
    CharacterService,
    VehicleService
  ]
})
@RouteConfig([
  { path: '/characters', name: 'Characters', component: CharacterListComponent, useAsDefault: true },
  { path: '/character/:id', name: 'Character', component: CharacterComponent },
  { path: '/vehicles', name: 'Vehicles', component: VehicleListComponent },
	{ path: '/vehicle/:id', name: 'Vehicle', component: VehicleComponent }
  ])
export class AppComponent { }
"><input type="hidden" name="files[app/characters/character-list.component.ts]" value="import { Component, OnInit } from 'angular2/core';
import { ROUTER_DIRECTIVES } from 'angular2/router';
import { Observable } from 'rxjs/Rx';

import { Character, CharacterService } from './character.service';

@Component({
  selector: 'story-characters',
  templateUrl: './app/characters/character-list.component.html',
  styles: [`
    .characters {list-style-type: none;}
    *.characters li {padding: 4px;cursor: pointer;}
  `],
  directives: [ROUTER_DIRECTIVES]
})
export class CharacterListComponent implements OnInit {
  characters: Observable<Character[]>;

  constructor(private _characterService: CharacterService) { }

  ngOnInit() {
    this.characters = this._characterService.getCharacters();
  }
}
"><input type="hidden" name="files[app/characters/character.component.ts]" value="import { Component, Input, OnInit } from 'angular2/core';
import { RouteParams, Router } from 'angular2/router';

import { Character, CharacterService } from '../characters/character.service';

@Component({
  selector: 'story-character',
  templateUrl: 'app/characters/character.component.html'
})
export class CharacterComponent implements OnInit {
  @Input() character: Character;

  constructor(
    private _characterService: CharacterService,
    private _routeParams: RouteParams,
    private _router: Router) { }

  ngOnInit() {
    if (!this.character) {
      let id = +this._routeParams.get('id');
      this._characterService.getCharacter(id)
        .subscribe(character => this._setEditCharacter(character));
    }
  }

  private _gotoCharacters() {
    let route = ['Characters', { id: this.character ? this.character.id : null }]
    this._router.navigate(route);
  }

  private _setEditCharacter(character: Character) {
    if (character) {
      this.character = character;
    } else {
      this._gotoCharacters();
    }
  }
}
"><input type="hidden" name="files[app/characters/character.service.ts]" value="import { Injectable } from 'angular2/core';
import { Http, Response } from 'angular2/http';

import { CONFIG } from '../config';

let charactersUrl = CONFIG.baseUrls.characters;

export interface Character {
  id: number;
  name: string;
  side: string;
}

@Injectable()
export class CharacterService {
  constructor(private _http: Http) { }

  getCharacters() {
    return this._http.get(charactersUrl)
      .map((response: Response) => <Character[]>response.json().data);
  }

  getCharacter(id: number) {
    return this.getCharacters()
      .map(characters => characters.find(character => character.id == id));
  }
}
"><input type="hidden" name="files[app/config.ts]" value="export let CONFIG = {
  baseUrls: {
    characters: 'api/characters.json',
    vehicles: 'api/vehicles.json'
  }
}
"><input type="hidden" name="files[app/main.ts]" value="import { bootstrap } from 'angular2/platform/browser';
import { AppComponent } from './app.component';

bootstrap(AppComponent, [])
  .then(success => console.log(`Bootstrap success`))
  .catch(error => console.log(error));
"><input type="hidden" name="files[app/vehicles/vehicle-list.component.ts]" value="import { Component, OnInit } from 'angular2/core';
import { ROUTER_DIRECTIVES } from 'angular2/router';

import { Vehicle, VehicleService } from './vehicle.service';

@Component({
  selector: 'story-vehicles',
  templateUrl: './app/vehicles/vehicle-list.component.html',
  styles: [`
    .vehicles {list-style-type: none;}
    *.vehicles li {padding: 4px;cursor: pointer;}
  `],
  directives: [ROUTER_DIRECTIVES]
})
export class VehicleListComponent implements OnInit {
  vehicles: Vehicle[];

  constructor(private _vehicleService: VehicleService) { }

  ngOnInit() {
    this.vehicles = [];
    this._vehicleService.getVehicles()
      .subscribe(vehicles => this.vehicles = vehicles);
  }
}
"><input type="hidden" name="files[app/vehicles/vehicle.component.ts]" value="import { Component, Input, OnInit } from 'angular2/core';
import { RouteParams, Router } from 'angular2/router';

import { Vehicle, VehicleService } from './vehicle.service';

@Component({
  selector: 'story-vehicle',
  templateUrl: 'app/vehicles/vehicle.component.html'
})
export class VehicleComponent implements OnInit {
  @Input() vehicle: Vehicle;

  constructor(
    private _routeParams: RouteParams,
    private _router: Router,
    private _vehicleService: VehicleService) { }

  ngOnInit() {
    if (!this.vehicle) {
      let id = +this._routeParams.get('id');
      this._vehicleService.getVehicle(id)
        .subscribe((vehicle: Vehicle) => this._setEditVehicle(vehicle));
    }
  }

  private _gotoVehicles() {
    let route = ['Vehicles', { id: this.vehicle ? this.vehicle.id : null }]
    this._router.navigate(route);
  }

  private _setEditVehicle(vehicle: Vehicle) {
    if (vehicle) {
      this.vehicle = vehicle;
    } else {
      this._gotoVehicles();
    }
  }
}
"><input type="hidden" name="files[app/vehicles/vehicle.service.ts]" value="import { Injectable } from 'angular2/core';
import { Http, Response } from 'angular2/http';

import { CONFIG } from '../config';

let vehiclesUrl = CONFIG.baseUrls.vehicles;

export interface Vehicle {
  id: number;
  name: string;
  type: string;
}

@Injectable()
export class VehicleService {
  constructor(private _http: Http) { }

  getVehicles() {
    return this._http.get(vehiclesUrl)
      .map((response: Response) => <Vehicle[]>response.json().data);
  }

  getVehicle(id: number) {
    return this.getVehicles()
      .map(vehicles => vehicles.find(vehicle => vehicle.id == id));
  }
}"><input type="hidden" name="files[app/app.component.html]" value="<div>
  <header>
    <h1>Storyline Tracker</h1>
    <h3>Router Demo</h3>
    <nav>
      <ul>
        <li><a [routerLink]=&quot;['Characters']&quot; href=&quot;&quot;>Characters</a></li>
        <li><a [routerLink]=&quot;['Vehicles']&quot; href=&quot;&quot;>Vehicles</a></li>
      </ul>
    </nav>
  </header>
  <main>
    <section>
      <router-outlet></router-outlet>
    </section>
  </main>
</div>"><input type="hidden" name="files[app/characters/character-list.component.html]" value="<article>
  <h4>My Characters</h4>

  <ul class=&quot;characters&quot;>
    <li *ngFor=&quot;#character of characters | async&quot;>
      <a href=&quot;&quot; [routerLink]=&quot;['Character', {id: character.id}]&quot;>
       {{character.id}}. {{character.name}}
      </a>
    </li>
  </ul>
</article>"><input type="hidden" name="files[app/characters/character.component.html]" value="<article>
  <div *ngIf=&quot;character&quot;>
    <h4>{{character.name}} details</h4>

    <div>
      <label for=&quot;nametext&quot;>Name</label>
      <input type=&quot;text&quot; id=&quot;nametext&quot; [(ngModel)]=&quot;character.name&quot; />
    </div>

    <div>
      <label for=&quot;typetext&quot;>Side</label>
      <input type=&quot;text&quot; id=&quot;typetext&quot; [(ngModel)]=&quot;character.side&quot; />
    </div>
  </div>
</article>"><input type="hidden" name="files[app/vehicles/vehicle-list.component.html]" value="<article>
  <h4>My Vehicles</h4>

  <ul class=&quot;vehicles&quot;>
    <li *ngFor=&quot;#vehicle of vehicles&quot;>
      <a href=&quot;&quot; [routerLink]=&quot;['Vehicle', {id: vehicle.id}]&quot;>
       {{vehicle.id}}. {{vehicle.name}}
      </a>
    </li>
  </ul>
</article>"><input type="hidden" name="files[app/vehicles/vehicle.component.html]" value="<article>
  <div *ngIf=&quot;vehicle&quot;>
    <h4>{{vehicle.name}} details</h4>

    <div>
      <label for=&quot;nametext&quot;>Name</label>
      <input type=&quot;text&quot; id=&quot;nametext&quot; [(ngModel)]=&quot;vehicle.name&quot; />
    </div>

    <div>
      <label for=&quot;typetext&quot;>Type</label>
      <input type=&quot;text&quot; id=&quot;typetext&quot; [(ngModel)]=&quot;vehicle.type&quot; />
    </div>
  </div>
</article>"><input type="hidden" name="files[index.html]" value="<!DOCTYPE html>
<html>

<head>
  <script>document.write('<base href=&quot;' + document.location + '&quot; />');</script>

  <meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;>

  <!-- IE required polyfills, in this exact order -->
  <script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.js&quot;></script>
  <script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.26/system-polyfills.js&quot;></script>
  <script src=&quot;https://npmcdn.com/angular2/es6/dev/src/testing/shims_for_IE.js&quot;></script>

  <!-- Angular polyfill required everywhere -->
  <script src=&quot;https://code.angularjs.org/2.0.0-beta.15/angular2-polyfills.js&quot;></script>

  <script src=&quot;https://code.angularjs.org/tools/system.js&quot;></script>
    <script src=&quot;https://code.angularjs.org/tools/typescript.js&quot;></script>
  <script src=&quot;https://code.angularjs.org/2.0.0-beta.15/Rx.js&quot;></script>
  <script src=&quot;https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js&quot;></script>
  <script src=&quot;https://code.angularjs.org/2.0.0-beta.15/router.dev.js&quot;></script>
  <script src=&quot;https://code.angularjs.org/2.0.0-beta.15/http.dev.js&quot;></script>

  <script>
      System.config({
        transpiler: 'typescript', 
        typescriptOptions: { emitDecoratorMetadata: true }, 
        packages: {
          'api': {defaultExtension: 'ts'}, 
          'app': {defaultExtension: 'ts'} 
        } 
      });
    System.import('app/main')
          .then(null, console.error.bind(console));
  </script>

</head>

<body>
  <story-app>Loading Storyline Tracker ...</story-app>
</body>

</html>"><input type="hidden" name="files[api/characters.json]" value="{
  &quot;data&quot;: [
    {
      &quot;id&quot;: 11,
      &quot;name&quot;: &quot;Chewbacca&quot;,
      &quot;side&quot;: &quot;light&quot;
    },
    {
      &quot;id&quot;: 12,
      &quot;name&quot;: &quot;Rey&quot;,
      &quot;side&quot;: &quot;light&quot;
    },
    {
      &quot;id&quot;: 13,
      &quot;name&quot;: &quot;Finn (FN2187)&quot;,
      &quot;side&quot;: &quot;light&quot;
    },
    {
      &quot;id&quot;: 14,
      &quot;name&quot;: &quot;Han Solo&quot;,
      &quot;side&quot;: &quot;light&quot;
    },
    {
      &quot;id&quot;: 15,
      &quot;name&quot;: &quot;Leia Organa&quot;,
      &quot;side&quot;: &quot;light&quot;
    },
    {
      &quot;id&quot;: 16,
      &quot;name&quot;: &quot;Luke Skywalker&quot;,
      &quot;side&quot;: &quot;light&quot;
    },
    {
      &quot;id&quot;: 17,
      &quot;name&quot;: &quot;Poe Dameron&quot;,
      &quot;side&quot;: &quot;light&quot;
    },
    {
      &quot;id&quot;: 18,
      &quot;name&quot;: &quot;Kylo Ren&quot;,
      &quot;side&quot;: &quot;dark&quot;
    },
    {
      &quot;id&quot;: 19,
      &quot;name&quot;: &quot;Supreme Commander Snoke&quot;,
      &quot;side&quot;: &quot;dark&quot;
    },
    {
      &quot;id&quot;: 20,
      &quot;name&quot;: &quot;R2-D2&quot;,
      &quot;side&quot;: &quot;light&quot;
    },
    {
      &quot;id&quot;: 21,
      &quot;name&quot;: &quot;BB8&quot;,
      &quot;side&quot;: &quot;light&quot;
    },
    {
      &quot;id&quot;: 22,
      &quot;name&quot;: &quot;C-3PO&quot;,
      &quot;side&quot;: &quot;light&quot;
    },
    {
      &quot;id&quot;: 23,
      &quot;name&quot;: &quot;Maz Kanata&quot;,
      &quot;side&quot;: &quot;light&quot;
    },
    {
      &quot;id&quot;: 24,
      &quot;name&quot;: &quot;Captain Phasma&quot;,
      &quot;side&quot;: &quot;dark&quot;
    },
    {
      &quot;id&quot;: 25,
      &quot;name&quot;: &quot;General Hux&quot;,
      &quot;side&quot;: &quot;dark&quot;
    },
    {
      &quot;id&quot;: 26,
      &quot;name&quot;: &quot;Lor San Tekka&quot;,
      &quot;side&quot;: &quot;light&quot;
    }
  ]
}"><input type="hidden" name="files[api/vehicles.json]" value="{
  &quot;data&quot;: [
    {
      &quot;id&quot;: 30,
      &quot;name&quot;: &quot;Millennium Falcon&quot;,
      &quot;type&quot;: &quot;space&quot;
    },
    {
      &quot;id&quot;: 31,
      &quot;name&quot;: &quot;Y-Wing Fighter&quot;,
      &quot;type&quot;: &quot;space&quot;
    },
    {
      &quot;id&quot;: 32,
      &quot;name&quot;: &quot;X-Wing Fighter&quot;,
      &quot;type&quot;: &quot;space&quot;
    },
    {
      &quot;id&quot;: 33,
      &quot;name&quot;: &quot;Imperial Star Destroyer&quot;,
      &quot;type&quot;: &quot;space&quot;
    },
    {
      &quot;id&quot;: 34,
      &quot;name&quot;: &quot;AT-AT Walker&quot;,
      &quot;type&quot;: &quot;land&quot;
    },
    {
      &quot;id&quot;: 35,
      &quot;name&quot;: &quot;TIE Fighter&quot;,
      &quot;type&quot;: &quot;space&quot;
    },
    {
      &quot;id&quot;: 36,
      &quot;name&quot;: &quot;B-Wing Fighter&quot;,
      &quot;type&quot;: &quot;space&quot;
    },
    {
      &quot;id&quot;: 37,
      &quot;name&quot;: &quot;ETA-2 Jedi Starfighter&quot;,
      &quot;type&quot;: &quot;space&quot;
    },
    {
      &quot;id&quot;: 38,
      &quot;name&quot;: &quot;TIE Interceptor&quot;,
      &quot;type&quot;: &quot;space&quot;
    },
    {
      &quot;id&quot;: 39,
      &quot;name&quot;: &quot;X-34 Landspeeder&quot;,
      &quot;type&quot;: &quot;land&quot;
    },
    {
      &quot;id&quot;: 40,
      &quot;name&quot;: &quot;Snow Speeder&quot;,
      &quot;type&quot;: &quot;land&quot;
    }
  ]
}"><input type="hidden" name="files[typings.json]" value="{
  &quot;ambientDependencies&quot;: {
    &quot;es6-shim&quot;: &quot;github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd&quot;,
    &quot;jasmine&quot;: &quot;github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#5c182b9af717f73146399c2485f70f1e2ac0ff2b&quot;
  }
}
"><input type="hidden" name="files[license.md]" value="Copyright 2010-2015 Google, Inc. http://angularjs.org

Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License."><input type="hidden" name="tags[0]" value="angular2"><input type="hidden" name="tags[1]" value="example"><input type="hidden" name="tags[2]" value="first look"><input type="hidden" name="tags[3]" value="angular 2"><input type="hidden" name="private" value="true"><input type="hidden" name="description" value="Angular 2 Example - Angular 2 - Router"></form><script>document.getElementById("mainForm").submit();</script></body></html>